local junxing = fk.CreateSkill {

  name = "joy__junxing",

  tags = {  },

}



junxing:addEffect("active", {
  name = "joy__junxing",
  anim_type = "control",
  min_card_num = 1,
  target_num = 1,
  prompt = "#joy__junxing",
  can_use = function(self, player)
    return player:usedSkillTimes(junxing.name, Player.HistoryPhase) == 0 and not player:isKongcheng()
  end,
  card_filter = function(self, player, to_select, selected)
    return Fk:currentRoom():getCardArea(to_select) ~= Player.Equip and not player:prohibitDiscard(Fk:getCardById(to_select))
  end,
  target_filter = function(self, player, to_select, selected)
    return #selected == 0 and to_select ~= player.id
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    local target = effect.tos[1]
    room:throwCard(effect.cards, junxing.name, player)
    if target.dead then return end
    local cards = room:askForDiscard(target,#effect.cards,#effect.cards,true, junxing.name, true, ".", "弃置"..#effect.cards.."张牌并失去一点体力，或翻面并摸"..#effect.cards.."张牌") 
    if target.dead then return end
    if #cards > 0 then
      room:loseHp(target,1,junxing.name)
    else
      target:turnOver()
      if not target.dead then
        target:drawCards(#effect.cards, junxing.name)
      end
    end
  end
})

return junxing